package com.zhouyu.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class MuseAspectJ {
	@Pointcut("execution(* *.goToWork(..))")
	public void goToWork() {
	}

	@Before("goToWork()")
	public void beforeGoToWork() {
		System.out.println("@Before：起床、洗漱、穿衣");
	}

	@After("goToWork()")
	public void afterGoToWork() {
		System.out.println("@After：开始工作了");
	}

	@Around("goToWork()")
	public Object aroundGoToWork(ProceedingJoinPoint point) {
		System.out.println("@Around-1：听一首摇滚歌曲提提神");
		Object result = null;
		try {
			result = point.proceed();
		} catch (Throwable e) {
			throw new RuntimeException(e);
		}
		System.out.println("@Around-2：听一首钢琴乐舒缓情绪");
		return result;
	}
}
